<!--Don't really need this-->

<%@ page import="gfo.Character" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'character.label', default: 'Character')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${fighterInstance}">
            <div class="errors">
                <g:renderErrors bean="${fighterInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${fighterInstance?.id}" />
                <g:hiddenField name="version" value="${fighterInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>

                        <tr class="prop">
                            <td valign="top" class="name">
                                <label for="name">Name</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: fighterInstance, field: 'name', 'errors')}">
                                <g:textField name="fullName" value="${fighterInstance?.name}"/>
                            </td>
                        </tr>

                        <tr class="prop">
                            <td valign="top" class="name">
                                <label for="description">Description</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: fighterInstance, field: 'description', 'errors')}">
                                <g:textField name="description" value="${fighterInstance?.description}"/>
                            </td>
                        </tr>

                        <tr class="prop">
                            <td valign="top" class="name">
                                <label for="imgFile">Image Filepath</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: fighterInstance, field: 'imgFile', 'errors')}">
                                <g:textField name="imgFile" value="${fighterInstance?.imgFile}"/>
                            </td>
                        </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="matches">Matches</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: fighterInstance, field: 'matches', 'errors')}">

                                    <ul>
                                        <g:each in="${fighterInstance?.matches?}" var="m">
                                            <li><g:link controller="matchship" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>
                                        </g:each>
                                    </ul>
                                    <g:link controller="matchship" action="create" params="['character.id': fighterInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'matchship.label', default: 'Matchship')])}</g:link>

                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
